home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Collections: Purity
/
Purity #48 (1995-06-25)(PackMAN)(DE)[WB].zip
/
Purity #48 (1995-06-25)(PackMAN)(DE)[WB].adf
/
Grafik
/
tridemo.p
< prev
next >
Wrap
Text File
|
1995-06-24
|
3KB
|
129 lines
program tridemo ( input, output ); { jr/7sep87 }
uses intuition,graphics; { aus modula2 umgesetzt (AMOK-Disk) }
const
WIDTH=320;
DEPTH=5;
POINTS=3;
var
scr: p_Screen;
rp: p_RastPort;
trp: ptr;
creg: integer;
MaxHeight: integer;
p: ptr;
type
VPoint=record
x, y, xv, yv: integer; { position and velocity of point }
end;
aofvpoint = array[0..points-1] of vpoint;
procedure MovePoint(var p: VPoint);
var n: integer;
begin
with p do begin
n:=x+xv;
if n>=WIDTH then begin { Bounce from right side }
xv:=-xv; x:=2*WIDTH-1-n
end else if n<0 then begin { Bounce from left side }
xv:=-xv; x:=-n
end
else begin
x:=n
end;
n:=y+yv;
if n>=MaxHeight then begin { Bounce from bottom side }
yv:=-yv; y:=2*MaxHeight-1-n
end else if n<11 then begin { Bounce from top side }
yv:=-yv; y:=21-n
end
else begin
y:=n
end
end
end;
procedure Show(var p: aofVPoint);
var i: integer; r:long;
begin
creg:=creg MOD 31+1; SetAPen(rp, creg);
r:=AreaMove(rp, p[0].x, p[0].y);
for i:=1 to POINTS-1 do begin
r:=AreaDraw(rp, p[i].x, p[i].y)
end;
r:=AreaEnd(rp)
end;
procedure Demo;
var
i: integer;
pts: array [0..POINTS-1] of VPoint;
frames: integer;
begin
for i:=0 to POINTS-1 do begin
with pts[i] do begin
x:=RANDOM(WIDTH); y:=RANDOM(MaxHeight);
repeat xv:=RANDOM(16)-8 until xv<>0;
repeat yv:=RANDOM(16)-8 until yv<>0
end
end;
for frames:=0 to 500 do begin
Show(pts);
for i:=0 to POINTS-1 do begin MovePoint(pts[i]) end
end
end;
procedure InitColors;
var
i: integer;
vp: p_ViewPort;
begin
vp:=^scr^.viewPort;
for i:=0 to 7 do begin
SetRGB4(vp, i, 8, 0, 8+i );
SetRGB4(vp, i+8, 8+i, 0, 15 );
SetRGB4(vp, i+16, 15, 0, 15-i);
SetRGB4(vp, i+24, 15-i, 0, 8 )
end;
SetRGB4(vp, 0, 0, 0, 0)
end;
procedure Cleanup;
var bool: boolean;
begin
if trp<>nil then begin FreeRaster(trp, WIDTH, MaxHeight) end;
if scr<>nil then begin Close_Screen(scr) end
end;
var
ai: AreaInfo;
tr: TmpRas;
abuf: array [0..POINTS*5] of integer;
begin
trp:=nil; scr:=nil;
scr:=Open_Screen(0,0,320, 256, 5,0,1,HAM,"TriDemo");
If scr=nil then ERROR('cannot open screen');
MaxHeight:=scr^.height;
rp:=^scr^.rastPort;
InitColors;
InitArea(^ai, ^abuf, SIZEOF(abuf) div 5);
trp:=AllocRaster(WIDTH, MaxHeight);
If trp=nil then ERROR('cannot alloc raster');
p:=InitTmpRas(^tr, trp, ((WIDTH+15) div 16) * MaxHeight);
rp^.areaInfo:=^ai;
rp^.tmpRas:=^tr;
Demo;
Cleanup
end.